package com.h2n.framework.composer;

import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zk.ui.util.ComposerExt;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.metainfo.ComponentInfo;
import org.apache.log4j.Logger;
import com.h2n.framework.dto.MemberDTO;
import com.h2n.framework.composer.PageConstantsFramework;

/**
 * Created by IntelliJ IDEA.
 * User: NhatNV
 * Date: Jul 30, 2009
 * Time: 12:49:24 AM
 * To change this template use File | Settings | File Templates.
 */
public class AbstractPageComposer extends GenericForwardComposer implements ComposerExt {
  protected static Logger logger;
  protected MemberDTO currentMemberLogined;

  public AbstractPageComposer(){
  }

  public void doAfterCompose(Component component)throws Exception{
    super.doAfterCompose(component);
    currentMemberLogined = (MemberDTO)session.getAttribute(PageConstantsFramework.SESSION_MEMBER_LOGINED);
//    System.out.println("AbstractComposer class : doAfterCompose(" + component + ")");
  }

  public ComponentInfo doBeforeCompose(Page page, Component component, ComponentInfo componentInfo){
//    System.out.println("AbstractComposer class : doBeforeCompose(" + page + ", " + component + ", " + componentInfo + ")");
    return componentInfo;
  }

  public ComponentInfo doComponentInfo(Page page,Component component,ComponentInfo componentInfo)throws Exception{
//    System.out.println("AbstractComposer class : doComponentInfo(" + page + ", " + component + ", " + componentInfo + ")");
    return componentInfo;
  }

  public void doBeforeComposeChildren(Component component)throws Exception{
//    System.out.println("AbstractComposer class : doBeforeComposeChildren(" + component + ")");
  }

  public boolean doCatch(Throwable throwable)throws Exception{
//    System.out.println("AbstractComposer class : doCatch(" + throwable + ")");
    return false;
  }

  public void doFinally()throws Exception{
//    System.out.println("AbstractComposer class : doFinally()");
  }

  public String getParentId() {
    Execution exec = Executions.getCurrent();
	  String parentId = exec!=null?exec.getParameter(PageConstantsFramework.PARAMETER_PARENT_ID):null;
    return parentId;
  }
}
